<?php
/**
 * Created by PhpStorm.
 * User: dream
 * Date: 2017/8/21
 * Time: 22:58
 */
class UserEventInfo extends MY_Model
{
    const TABLE_NAME = "user_event_info";
    const EVENT_LOGOUT = "退出";
    const EVENT_LOGIN = "登录";
    const EVENT_RESET_PSW = "重置密码";
    private $ci = null;

    public function __construct($table_name=self::TABLE_NAME)
    {

        parent::__construct($table_name);
        $this->ci = &get_instance();
    }

    public function add_event_log($event_name,$ctime)
    {
        $this->ci->load->library("session");
        $user_id = $this->ci->session->userdata("user")->id;
        $db_ip_info = $this->ci->session->userdata("ip_info");
        $ip = $this->ci->session->userdata("ip");
        $event =
            [
                'ip_addr'=>$ip,
                'login_address'=>implode("/",$db_ip_info),
                'ctime'=>$ctime,
                'event_name'=>$event_name,
                'user_id'=>$user_id
            ];
       $res =  $this->usereventinfo->add($event);
       return $res;
    }




}